import datetime
import os

import service.simple_service
import uvicorn
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from starlette.responses import HTMLResponse, RedirectResponse


def include_router():
    path = os.getcwd()
    # 将静态文件目录设置为 vue/dist 目录#
    app.mount("/vue", StaticFiles(directory=f"{path}/vue/dist"), name="vue")

    @app.get("/", response_class=HTMLResponse)
    async def get_index_page():
        return RedirectResponse(f"/vue/index.html")

    app.include_router(service.simple_service.router)


if __name__ == "__main__":
    app = FastAPI()
    # 挂载路由
    include_router()
    uvicorn.run(app, host="127.0.0.1", port=8000)
